GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Date.rangePicker   B
last analyzed

Complexity

Conditions 2

Size

Total Lines 74
Code Lines 61

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 61
dl 0
loc 74
rs 8.2763
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
/**
2
 * This file is part of the O2System Venus UI Framework package.
3
 *
4
 * For the full copyright and license information, please view the LICENSE
5
 * file that was distributed with this source code.
6
 *
7
 * @author         Steeve Andrian Salim
8
 * @copyright      Copyright (c) Steeve Andrian Salim
9
 */
10
// ------------------------------------------------------------------------
11
12
import * as $ from 'jquery';
13
import * as moment from 'moment';
14
import 'bootstrap-datepicker';
15
import 'bootstrap-daterangepicker';
16
17
18
/**
19
 * Class Date
20
 * 
21
 * @author          Teguh Rianto
22
 * @package         Components/Input
23
 */
24
export default class Date {
25
    constructor() {
26
        /**
27
         * Initiate basic date picker
28
         */
29
        this.basicPicker();
30
31
        /**
32
         * Initiate range date picker
33
         */
34
        this.rangePicker();
35
    }
36
37
    // ------------------------------------------------------------------------
38
39
    /**
40
     * Date.basicPicker
41
     */
42
    basicPicker() {
43
        // Date Picker
44
        $('.datepicker').datepicker();
45
        $('.datepicker-autoclose').datepicker({
46
            autoclose: true,
47
            todayHighlight: true
48
        });
49
        $('.datepicker-inline').datepicker();
50
        $('.datepicker-multiple-date').datepicker({
51
            format: "mm/dd/yyyy",
52
            clearBtn: true,
53
            multidate: true,
54
            multidateSeparator: ","
55
        });
56
        $('.date-range').datepicker({
57
            toggleActive: true
58
        });
59
    }
60
61
    // ------------------------------------------------------------------------
62
63
    /**
64
     * Date.rangePicker
65
     */
66
    rangePicker(){
67
        //Date range picker
68
        $('.input-daterange-datepicker').daterangepicker({
69
            buttonClasses: ['btn', 'btn-sm'],
70
            applyClass: 'btn-success',
71
            cancelClass: 'btn-light'
72
        });
73
        $('.input-daterange-timepicker').daterangepicker({
74
            timePicker: true,
75
            timePickerIncrement: 30,
76
            locale: {
77
                format: 'MM/DD/YYYY h:mm A'
78
            },
79
            buttonClasses: ['btn', 'btn-sm'],
80
            applyClass: 'btn-success',
81
            cancelClass: 'btn-light'
82
        });
83
        $('.input-limit-datepicker').daterangepicker({
84
            format: 'MM/DD/YYYY',
85
            minDate: '06/01/2018',
86
            maxDate: '06/30/2018',
87
            buttonClasses: ['btn', 'btn-sm'],
88
            applyClass: 'btn-success',
89
            cancelClass: 'btn-light',
90
            dateLimit: {
91
                days: 6
92
            }
93
        });
94
95
        $('.reportrange span').html(moment().subtract(29, 'days').format('MMMM D, YYYY') + ' - ' + moment().format('MMMM D, YYYY'));
96
97
        $('.reportrange').daterangepicker({
98
            format: 'MM/DD/YYYY',
99
            startDate: moment().subtract(29, 'days'),
100
            endDate: moment(),
101
            minDate: '01/01/2017',
102
            maxDate: '12/31/2020',
103
            dateLimit: {
104
                days: 60
105
            },
106
            showDropdowns: true,
107
            showWeekNumbers: false,
108
            timePicker: false,
109
            timePickerIncrement: 1,
110
            timePicker12Hour: true,
111
            ranges: {
112
                'Today': [moment(), moment()],
113
                'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
114
                'Last 7 Days': [moment().subtract(6, 'days'), moment()],
115
                'Last 30 Days': [moment().subtract(29, 'days'), moment()],
116
                'This Month': [moment().startOf('month'), moment().endOf('month')],
117
                'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
118
            },
119
            opens: 'left',
120
            drops: 'down',
121
            buttonClasses: ['btn', 'btn-sm'],
122
            applyClass: 'btn-success',
123
            cancelClass: 'btn-light',
124
            separator: ' to ',
125
            locale: {
126
                applyLabel: 'Submit',
127
                cancelLabel: 'Cancel',
128
                fromLabel: 'From',
129
                toLabel: 'To',
130
                customRangeLabel: 'Custom',
131
                daysOfWeek: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
132
                monthNames: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
133
                firstDay: 1
134
            }
135
        }, function (start, end, label) {
136
            console.log(start.toISOString(), end.toISOString(), label);
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
137
            $('.reportrange span').html(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY'));
138
        });
139
    }
140
}